package com.example.rvdemo.common;

import android.app.Activity;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.rvdemo.R;

import java.util.ArrayList;
import java.util.List;

public class CommonRVActivity extends Activity {
    private RecyclerView rv_common;
    private List<ChatData> mDatas;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.rv_common);
        rv_common = findViewById(R.id.rv_common);
        mDatas = new ArrayList<>();
        for (int i = 0; i < 100; i++) {
            ChatData chatData;
            if (i % 3 == 0) {
                chatData = new ChatData("自己内容" + i, 1);
            } else {
                chatData = new  ChatData("朋友内容" + i, 0);
            }
            mDatas.add(chatData);
        }
        rv_common.setLayoutManager(new LinearLayoutManager(this));
        rv_common.setAdapter(new ChatAdaptar(this,mDatas));

    }


}
